//
//  UISwitchViewController.m
//  UITest
//
//  Created by wp w on 12-6-9.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UISwitchViewController.h"
#import "DLog.h"

@interface UISwitchViewController ()

@end

@implementation UISwitchViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)switchAction:(id)sender
{
	NSLog(@"switch changed");
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    //UISwitch大小时固定的，所以设置frame时只需要设置坐标
    CGRect switchRect = CGRectMake(10,10,0,0);
	UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:switchRect];
	[mySwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:mySwitch];
    LogSubViews(mySwitch);
    for (UIView *subview in [mySwitch subviews]) {
        LogSubViews(subview);
    }
    
    [mySwitch release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
